
% CUT_FREQ = 5000,000000;
% ORDER 2 : COEF = [ 0,077806 -1,070930 0,382156 2,000000 1,000000  ];
% ORDER 4 : COEF = [ 0,006443 -1,247784 0,610406 2,000000 1,000000 -0,978283 0,262584 2,000000 1,000000  ];
% ORDER 6 : COEF = [ 0,000526 -1,331752 0,718776 2,000000 1,000000 -1,070930 0,382156 2,000000 1,000000 -0,962138 0,241747 2,000000 1,000000  ];

NUM_2 =  0.077806 .* [ 1.000000 2.000000 1.000000 ]; DENO_2  = [1.000000 -1.070930  0.382156 ];
NUM_4 =  0.006443 .* [ 1.000000 4.000000 6.000000 4.000000 1.000000 ] ; DENO_4 = [ 1 -2.22607 2.09368 0.924798 0.160283 ];
NUM_6 =  0.000526 .* [1 6 15 20 15 6 1]; DENO_6 = [1 -3.36482 5.0806 -4.291 2.1159 0.573405 0.66404 ];

close
[H_2 W_2] = freqz(NUM_2, DENO_2);
[H_4 W_4] = freqz(NUM_4, DENO_4);
[H_6 W_6] = freqz(NUM_6, DENO_6);

f_2 =W_2.*44100/(2*pi);
f_4 =W_4.*44100/(2*pi);
f_6 =W_6.*44100/(2*pi);

gr = semilogy((f_2), abs(H_2),'-r',(f_4), abs(H_4),'b',(f_6), abs(H_6),'g');
set (gr(1), "linewidth", 2)
set (gr(2), "linewidth", 2)
set (gr(3), "linewidth", 2)
legend("Order 2","Order 4","Order 6");
title("Respuesta del filtro IIR para diferente orden",'FontSize',20)
xlabel("Frecuencia (Hz)",'FontSize',14)
ylabel("log(|H(z)|)",'FontSize',14)
print -deps iir_order_test.eps -color


